<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.gzgi.framework.*"%>
<%@ page import="com.gzgi.framework.util.*"%>
<%@ page import="com.gzgi.framework.context.*"%>
<%@ page import="com.gzgi.framework.config.*"%>
<%@ page import="com.gzgi.framework.tree.*"%>
<%@ page import="com.gzgi.framework.tree.helper.*"%>
<%
		  DTreeHelper helper = new DTreeHelper();
		  TreeNodeService treeNodeService = (TreeNodeService) ContextFactory.getBean("treeNodeService");
		  List treeNodes = treeNodeService.getChildTreeNodes("SYS_MENU");
		  TreeNode root = treeNodeService.getTreeNodeByCode("SYS_MENU");
		  treeNodes.add(root);
		  String script = helper.buildTreeScript(treeNodes,"tree", true);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<title>DTree</title>
	<link rel="StyleSheet" href="<%=request.getContextPath()%>/scripts/dtree/dtree.css" type="text/css" />
	<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/dtree/dtree.js"></script>
	<script type="text/javascript">
        function gotoLink(link){
           location.herf="<%=request.getContextPath()%>"+link;
        }

		function submitForm(){
			var ids = "";
			var form = document.getElementById("iForm");
			for (var i=0; i<form.elements.length; i++) {
				var element = form.elements[i];
				if (element.name == "id" && element.type=='checkbox'){
					if( element.checked == true ){
						ids = ids + element.value + ",";
					}
				}
			}		
			alert("ids = " + ids);
		}
		
	</script>
</head>
<body>
<form id="iForm">
<div class="dtree">
 	<p><a href="javascript: tree.openAll();">全部展开</a> | <a href="javascript: tree.closeAll();">全部收缩</a></p>
     <script language="javascript">
	    var iPath = "<%=request.getContextPath()%>/scripts/dtree";
	    var tree = new dTree("tree", iPath, "iForm");
        tree.config.target = "_blank";
		tree.config.useIcons = true;
		tree.config.useCheckBox = true;
        <%=script%>
		document.write(tree);
     </script>
	<input type="button" value="提 交" onClick="submitForm()"/>

</div>
</form>
</body>

</html>